package com.ymttest.database.sqlwapper.thirdpartysync;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.database.SqlManager;
import com.ymttest.database.mapping.thirdpartysync.promoterproductMapper;
import com.ymttest.database.mapping.thirdpartysync.promoterproductcommissionMapper;
import com.ymttest.database.mapping.thirdpartysync.promotionproductMapper;
import com.ymttest.database.model.Mchapp;
import com.ymttest.database.model.MchappExample;
import com.ymttest.database.model.YmtAccountEntry;
import com.ymttest.database.model.permission;
import com.ymttest.database.model.thirdpartysync.fenqilebrand;
import com.ymttest.database.model.thirdpartysync.fenqilebrandExample;
import com.ymttest.database.model.thirdpartysync.fenqilecategory;
import com.ymttest.database.model.thirdpartysync.fenqilecategoryExample;
import com.ymttest.database.model.thirdpartysync.fenqileproduct;
import com.ymttest.database.model.thirdpartysync.fenqileproductExample;
import com.ymttest.database.model.thirdpartysync.fenqilesku;
import com.ymttest.database.model.thirdpartysync.fenqileskuExample;
import com.ymttest.database.model.thirdpartysync.promoter;
import com.ymttest.database.model.thirdpartysync.promoterExample;
import com.ymttest.database.model.thirdpartysync.promoterproduct;
import com.ymttest.database.model.thirdpartysync.promoterproductExample;
import com.ymttest.database.model.thirdpartysync.promoterproductcommission;
import com.ymttest.database.model.thirdpartysync.promoterproductcommissionExample;
import com.ymttest.database.model.thirdpartysync.promotionproduct;
import com.ymttest.database.model.thirdpartysync.promotionproductExample;
import com.ymttest.database.model.thirdpartysync.promotionproductExample.Criteria;
import com.ymttest.database.model.withdraw.*;
import com.ymttest.utils.EnvSetup;

public class DefThirdpartysyncWapper {
	SqlManager manager;
	public DefThirdpartysyncWapper() {
		
		manager = new SqlManager("thirdpartysync" + EnvSetup.getEnv());
	}
	
	public static void main(String[] args) throws InterruptedException {
		DefThirdpartysyncWapper defThirdpartysyncWapper = new DefThirdpartysyncWapper();
		List<promotionproduct> selectPromotionproduct = defThirdpartysyncWapper.selectPromotionproduct("123");
		
	}
	
	
	/**
	 * 查询所有达人信息
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public List<promoter> selectAllpromoters() throws InterruptedException {
		
		promoterExample pe = new promoterExample();
		com.ymttest.database.model.thirdpartysync.promoterExample.Criteria c = pe.createCriteria();
		List<promoter> list = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.promoterMapper.selectByExample", pe);
		manager.commit();
		return list;
	}
	
	/**
	 * 添加商品到推广商品表
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public int insertPromotionProduct(promotionproduct product) throws InterruptedException {
		int i = manager.insert("com.ymttest.database.mapping.thirdpartysync.promotionproductMapper.insertSelective", product);
		manager.commit();
		return i;
	}
	
	/**
	 * 添加商品到达人佣金表
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public int insertPromoterProductCommission(promoterproductcommission promoterproductcommission) throws InterruptedException {
		int i = manager.insert("com.ymttest.database.mapping.thirdpartysync.promoterproductcommissionMapper.insertSelective", promoterproductcommission);
		manager.commit();
		return i;
	}
	
	
	/**
	 * 根据商品id查询promotionproduct
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public List<promotionproduct> selectPromotionproduct(String productId) throws InterruptedException {
		promotionproductExample pe = new promotionproductExample();
		Criteria c = pe.createCriteria();
		c.andProductIdEqualTo(productId);
		List<promotionproduct> list = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.promotionproductMapper.selectByExample", pe);
		manager.commit();
		return list;
	}
	
	
	/**
	 * 根据商品id查询promoterproductcommission达人费率
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public List<promoterproductcommission> selectPromoterProductCommission(String productId) throws InterruptedException {
		promoterproductcommissionExample pe = new promoterproductcommissionExample();
		com.ymttest.database.model.thirdpartysync.promoterproductcommissionExample.Criteria c = pe.createCriteria();
		c.andProductIdEqualTo(productId);
		List<promoterproductcommission> list = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.promoterproductcommissionMapper.selectByExample", pe);
		manager.commit();
		return list;
	}
	
	/**
	 * 根据商品id查询promoterproduct
	 * 
	 * @param roleid
	 * @return
	 * @throws InterruptedException
	 */
	public List<promoterproduct> selectPromoterProduct(String productId) throws InterruptedException {
		
		promoterproductExample pe = new promoterproductExample();
		com.ymttest.database.model.thirdpartysync.promoterproductExample.Criteria c = pe.createCriteria();
		c.andProductIdEqualTo(productId);
		List<promoterproduct> list = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.promoterproductMapper.selectByExample", pe);
		manager.commit();
		return list;
	}

	/** 
	 * 查询selectfenqilecategory 表查询分类明细
	 * 
	 * @param ymtflowlog
	 * @return
	 * @throws InterruptedException
	 */
	public List<fenqilecategory> selectByExample(fenqilecategoryExample category) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<fenqilecategory> pia = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.fenqilecategoryMapper.selectByExample", category);
		manager.commit();
		return pia;
	}
	
	
	/** 
	 * 查询fenqilebrand 表查询分类明细
	 * 
	 * @param ymtflowlog
	 * @return
	 * @throws InterruptedException
	 */
	public List<fenqilebrand> selectByExample(fenqilebrandExample brand) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<fenqilebrand> pia = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.fenqilebrandMapper.selectByExample", brand);
		manager.commit();
		return pia;
	}
	
	
	/** 
	 * 查询fenqileproduct 表查询分期乐商品
	 * 
	 * @param fenqileproduct
	 * @return
	 * @throws InterruptedException
	 */
	public List<fenqileproduct> selectByExample(fenqileproductExample product) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<fenqileproduct> pia = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.fenqileproductMapper.selectByExample", product);
		manager.commit();
		return pia;
	}
	
	
	/** 
	 * 查询fenqilesku 表查询分期乐商品sku
	 * 
	 * @param fenqileproduct
	 * @return
	 * @throws InterruptedException
	 */
	public List<fenqilesku> selectByExample(fenqileskuExample fenqilesku) throws InterruptedException {
		@SuppressWarnings("unchecked")
		List<fenqilesku> pia = manager.getSelectResults("com.ymttest.database.mapping.thirdpartysync.fenqileskuMapper.selectByExample", fenqilesku);
		manager.commit();
		return pia;
	}
	
	
	
	
	/**
	 * 关闭数据库连接
	 */
	public void close() {
		manager.close();
	}

	@Override
	protected void finalize() throws Throwable {
		this.close();
		manager = null;
		super.finalize();
	}

//	public static void main(String args[]) {
//		try {
//			fenqilecategoryWapper WithdrawWapper=new fenqilecategoryWapper();
//			System.out.println("冻结金额："+WithdrawWapper.getSumFreezebyUserId(3383));
//			
//			
//			System.out.println("selectYmtInvoiceFundFlowLogByExample");
//			Ymt_InvoiceFundFlowLogExample ymtflowlog=new Ymt_InvoiceFundFlowLogExample();
//			ymtflowlog.createCriteria().andInvoiceIdEqualTo("FKK2019041710184687").andUserIdEqualTo(3383).andAccountTypeEqualTo(1).andFundFlowLogIdEqualTo("e4cb628e-8ba6-4de6-b572-aa8c2f650eaa");
//			ymtflowlog.setOrderByClause("createTime desc");
//			List<Ymt_InvoiceFundFlowLog> flowlist = WithdrawWapper.selectYmtInvoiceFundFlowLog(ymtflowlog);
//			flowlist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			System.out.println("Ymt_InvoiceOperationLogExample");
//			Ymt_InvoiceOperationLogExample ymtoplog=new Ymt_InvoiceOperationLogExample();
//			ymtoplog.createCriteria().andInvoiceIdEqualTo("FKK2019041710184687").andOperationLogIdEqualTo("0002e184-773c-40ab-967e-bbf91936c7fc");
//			ymtoplog.setOrderByClause("operationtime desc");
//			List<Ymt_InvoiceOperationLog> oplist = WithdrawWapper.selectYmtInvoiceOperationLog(ymtoplog);
//			oplist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_InvoiceSerialSeed");
//			Ymt_InvoiceSerialSeedExample ymseedlog=new Ymt_InvoiceSerialSeedExample();
//			ymseedlog.createCriteria().andSerialNumberEqualTo(10000656l);
//			ymseedlog.setOrderByClause("createtime desc");
//			List<Ymt_InvoiceSerialSeed> seedlist = WithdrawWapper.selectYmtInvoiceSerialSeed(ymseedlog);
//			seedlist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_WithDrawInvoiceExample");
//			Ymt_WithDrawInvoiceExample wdlog=new Ymt_WithDrawInvoiceExample();
//			wdlog.createCriteria().andApplyUserIdEqualTo(3383).andAccountTypeEqualTo(11).andWithDrawInvoiceIdEqualTo("FTX2017082310140239");
//			wdlog.setOrderByClause("updatetime desc");
//			List<Ymt_WithDrawInvoice> wdlist = WithdrawWapper.selectYmtWithDrawInvoice(wdlog);
//			wdlist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_WithDrawIdempotentExample");
//			Ymt_WithDrawIdempotentExample ide=new Ymt_WithDrawIdempotentExample();
//			ide.createCriteria().andWithDrawInvoiceIdEqualTo("FTX2019020110183029");
//			ide.setOrderByClause("updatetime desc");
//			List<Ymt_WithDrawIdempotent> idelist = WithdrawWapper.selectYmtWithDrawIdempotent(ide);
//			idelist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			//selectYmtWithDrawInvoiceXloboLog
//			System.out.println("Ymt_WithDrawInvoiceXloboLogExample");
//			Ymt_WithDrawInvoiceXloboLogExample ymtxlb=new Ymt_WithDrawInvoiceXloboLogExample();
//			ymtxlb.createCriteria().andWithDrawInvoiceIdEqualTo("FTX2017091210140449");
//			ymtxlb.setOrderByClause("updatetime desc");
//			List<Ymt_WithDrawInvoiceXloboLog> xlblist = WithdrawWapper.selectYmtWithDrawInvoiceXloboLog(ymtxlb);
//			xlblist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_WithDrawXloboMapping");
//			Ymt_WithDrawXloboMappingExample ymtxlbmp=new Ymt_WithDrawXloboMappingExample();
//			ymtxlbmp.createCriteria().andSellerIdEqualTo(3383);
//			ymtxlbmp.setOrderByClause("updatetime desc");
//			List<Ymt_WithDrawXloboMapping> xlbmplist = WithdrawWapper.selectYmtWithDrawXloboMapping(ymtxlbmp);
//			xlbmplist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			
//			System.out.println("Ymt_AbroadFundAccountExample");
//			Ymt_AbroadFundAccountExample fundacc=new Ymt_AbroadFundAccountExample();
//			fundacc.createCriteria().andSLoginIdEqualTo("wesper").andIActionEqualTo(0).andSAccountNameEqualTo("dw");
//			fundacc.setOrderByClause("daddtime desc");
//			List<Ymt_AbroadFundAccount> falist = WithdrawWapper.selectYmtAbroadFundAccount(fundacc);
//			falist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_FundAccountExample");
//			Ymt_FundAccountExample fund=new Ymt_FundAccountExample();
//			fund.createCriteria().andSLoginIdEqualTo("wesper").andIActionEqualTo(0).andSAccountNameEqualTo("支付宝001");
//			fund.setOrderByClause("daddtime desc");
//			List<Ymt_FundAccount> flist = WithdrawWapper.selectYmtFundAccount(fund);
//			flist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_fundRateExpression");
//			Ymt_fundRateExpressionExample frund=new Ymt_fundRateExpressionExample();
//			frund.createCriteria().andRateIdEqualTo(1);
//			frund.setOrderByClause("updatetime desc");
//			List<Ymt_fundRateExpression> frlist = WithdrawWapper.selectYmtFundRateExpression(frund);
//			frlist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//			
//			System.out.println("Ymt_WithDrawInvoiceExample");
//			Ymt_WithDrawInvoiceExExample wdex=new Ymt_WithDrawInvoiceExExample();
//			wdex.createCriteria().andWithDrawInvoiceIdEqualTo("FTX2017082910140341");
//			wdex.setOrderByClause("createtime desc");
//			List<Ymt_WithDrawInvoiceEx> wdexlist = WithdrawWapper.selectYmtWithDrawInvoiceEx(wdex);
//			wdexlist.forEach(data->{
//				System.out.println(FormatUtil.beanToGSONString(data));
//				
//			});
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//	}
}
